import * as React from 'react';
import { View, Text, Image, navigateTo, canIUse, OpenData } from 'remax/wechat';
import './index.less';

export default () => {
  let nav = () => {
    navigateTo({
      url: '/pages/todo/todo',
    });
  }
  let navToList = () => {
    navigateTo({
      url: '/pages/projectList/projectList'
    })
  }
  let canIUseOpenData = canIUse('open-data.type.userAvatarUrl') && canIUse('open-data.type.userNickName') // 如需尝试获取用户信息可改为false
  let userInfo = canIUseOpenData ? 
    <View>
      <View class="userinfo-avatar" onClick={nav}>
        <OpenData type="userAvatarUrl"></OpenData>
      </View>
      <OpenData type="userNickName"></OpenData>
    </View>
    : <View></View>
  return (
    <View className="container">
      <View className="userinfo">
        {userInfo}
      </View>
      <View className="usermotto" onClick={navToList}>
        <Text className="user-motto">Hello Remax</Text>
      </View>
    </View>
  );
};
